﻿function applyAwesomeStyles() {
    $(".lookupButton").empty().prepend('<span class="ui-icon ui-icon-newwin"></span>');
    $(".clearLookupButton").empty().prepend('<span class="ui-icon ui-icon-gear"></span>');
    mybutton(".lookupButton");
    mybutton(".clearLookupButton");
}

$(function () {
    $(".pagination .current").addClass('ui-state-highlight');
    mybutton(".pagination a");
    applyAwesomeStyles();
    $("body").ajaxComplete(applyAwesomeStyles);
});

function mybutton(sel) {
    $(sel).unbind('mousedown mouseup mouseleave')
        .hover(function () { $(this).addClass("ui-state-hover"); },
	            function () { $(this).removeClass("ui-state-hover"); })
        .bind({ 'mousedown mouseup': function () { $(this).toggleClass('ui-state-active'); } })
        .addClass("ui-state-default").addClass("ui-corner-all")
        .bind('mouseleave', function () { $(this).removeClass('ui-state-active') });
}

function OpenConfirm(message, functionYes, functionNo) {
    var obj = $("<div>").attr("class", "custom-confirm").attr("title", "Are you sure?");

    obj.dialog({
        hide: "fade",
        width: "450px",
        resizable: false,
        modal: true,
        buttons: {
            "Yes": function () {
                obj.remove();
                functionYes();
            },

            "Cancel": function () {
                obj.remove();
                functionNo();
            }
        }

    });

    $("<div>").attr("class", "text").text(message).appendTo(obj);

    var line = $("<div>").attr("class", "line").appendTo(obj);
}

function SuccessMessageBox(message) {
    var obj = $("<div>").attr("class", "custom-confirm").attr("title", "Message");

    obj.dialog({
        width: "450px",
        resizable: false,
        modal: true,
        buttons: {
            Ok: function () {
                $(this).dialog("close");
            }
        }
    });

    $("<div>").attr("class", "ErrorMessage").text(message).appendTo(obj);
}